package main

import "fmt"

/**
闭包举例
*/
func main() {
	nextInt := intSeq()
	fmt.Println(nextInt())
	fmt.Println(nextInt())
	fmt.Println(nextInt())

	newInt := intSeq()
	fmt.Println(newInt())
	fmt.Println(newInt())

}

func intSeq() func() int {
	i := 0
	return func() int {
		i += 1
		return i
	}
}
